package com.luojing.innerclass.controllerframework;

import java.util.ArrayList;
import java.util.List;

/**
 * @author luojing
 * @create 2018/09/08 上午11:38
 **/
public class Controller {
  private List<Event> eventList = new ArrayList<>();

  public void addEvent(Event event){
    eventList.add(event);
  }

  public void run(){
    while(eventList.size() > 0){
      for(Event e : new ArrayList<>(eventList)){
        if(e.ready()){
          System.out.println(e);
          e.action();
          eventList.remove(e);
        }
      }
    }
  }

}
